package quotation.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum KvStoreEnum {

    QES_coefficient("QES", "coefficient", "0.64", "QES成本系数"),
    QES_person("QES", "person", "650", "人天费用"),
    QES_cost("QES", "cost", "1100", "成本"),
    QES_cost_external("QES", "cost_external", "300", "外部报价费用"),
    IPMS_risk("IPMS", "risk", "0.7", "IPMS风险系数"),
    IPMS_fixed_location("IPMS", "fixed_location", "0.5", "固定场所系数"),
    IPMS_temporary_location("IPMS", "temporary_location", "0.25", "临时场所系数"),
    IPMS_manage("IPMS", "manage", "2000", "管理费"),
    IPMS_person_day("IPMS", "person_day", "800", "人天费"),
    IPMS_consulting("IPMS", "consulting", "500", "咨询费"),
    ;

    // 分组名称
    private final String group;

    // 键
    private final String key;

    // 默认值
    private final String defaultValue;

    // 描述
    private final String describe;


    /**
     * 根据group获取对应的枚举列表。如果group为null或空，则返回所有枚举。
     *
     * @param group 分组名称
     * @return 匹配的枚举列表
     */
    public static List<KvStoreEnum> getByGroup(String group) {
        if (group == null || group.isEmpty()) {
            // 如果group为空，返回所有枚举
            return Arrays.stream(values()).collect(Collectors.toList());
        } else {
            // 过滤出符合group条件的枚举
            return Arrays.stream(values())
                    .filter(item -> item.getGroup().equals(group))
                    .collect(Collectors.toList());
        }
    }


}
